//
//  MPTViewController.m
//  MPTUILibrary
//
//  Created by 蔡勋 on 07/14/2017.
//  Copyright (c) 2017 蔡勋. All rights reserved.
//

#import "MPTViewController.h"
#import <StoreKit/StoreKit.h>
#import "MPFImageCell.h"


@interface MPTViewController ()
<
UITableViewDelegate,
UITableViewDataSource
>
{
    NSArray *aryImags;
}

@end

@implementation MPTViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    aryImags = @[@"http://bsyimg5.cdn.krcom.cn/images/7WLvEGdoiXMo9QppB4I5zWYct0KCDmHt_a2lj_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/wBTVxq~aWUYeu8rceoc6NHN1UibFkU99_w7y6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/AmuE79AkACQM-u-Qy3Fdbuodyx2b4cHA_4wjt_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/IkPk9bwnpYO3tMSunoAKeBROQJVNedCt_pe0v_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/4B0ETQDACUPTzQHvzyWMJzHk0joLh21K_nhk6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/7ZYPV0jgVHxxzJIdbR5yiH-GKoXCrNDX_otu9_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/ewAq4X7gTEkxyiuFm9xgXhVT2pcOaHxM_48xa_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/CYXSqy5mPA-1dYvUZYN5yz7qLgFYIG1Z_gxtd_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/VHaqnjlgsQZ0BcyZL5qROqLrKolY0DJr_okeq_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/pz9XeWUyuebWC2x1JKy93P1RbgXwSpA3_s7dj_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/jWnParFNoWiFn782tFanJCIUxnGifnfY_2jjo_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/wrwERUDnDJLnhKSOWHN6HQljA~z8s7-z_awsb_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/vat4CSzeF5QqbTFs8Seiof0Xm73khTgU_tqmc_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/7WLvEGdoiXMo9QppB4I5zWYct0KCDmHt_a2lj_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/wBTVxq~aWUYeu8rceoc6NHN1UibFkU99_w7y6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/AmuE79AkACQM-u-Qy3Fdbuodyx2b4cHA_4wjt_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/IkPk9bwnpYO3tMSunoAKeBROQJVNedCt_pe0v_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/4B0ETQDACUPTzQHvzyWMJzHk0joLh21K_nhk6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/7ZYPV0jgVHxxzJIdbR5yiH-GKoXCrNDX_otu9_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/ewAq4X7gTEkxyiuFm9xgXhVT2pcOaHxM_48xa_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/CYXSqy5mPA-1dYvUZYN5yz7qLgFYIG1Z_gxtd_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/VHaqnjlgsQZ0BcyZL5qROqLrKolY0DJr_okeq_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/pz9XeWUyuebWC2x1JKy93P1RbgXwSpA3_s7dj_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/jWnParFNoWiFn782tFanJCIUxnGifnfY_2jjo_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/wrwERUDnDJLnhKSOWHN6HQljA~z8s7-z_awsb_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/vat4CSzeF5QqbTFs8Seiof0Xm73khTgU_tqmc_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/7WLvEGdoiXMo9QppB4I5zWYct0KCDmHt_a2lj_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/wBTVxq~aWUYeu8rceoc6NHN1UibFkU99_w7y6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/AmuE79AkACQM-u-Qy3Fdbuodyx2b4cHA_4wjt_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/IkPk9bwnpYO3tMSunoAKeBROQJVNedCt_pe0v_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/4B0ETQDACUPTzQHvzyWMJzHk0joLh21K_nhk6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/7ZYPV0jgVHxxzJIdbR5yiH-GKoXCrNDX_otu9_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/ewAq4X7gTEkxyiuFm9xgXhVT2pcOaHxM_48xa_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/CYXSqy5mPA-1dYvUZYN5yz7qLgFYIG1Z_gxtd_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/VHaqnjlgsQZ0BcyZL5qROqLrKolY0DJr_okeq_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/pz9XeWUyuebWC2x1JKy93P1RbgXwSpA3_s7dj_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/jWnParFNoWiFn782tFanJCIUxnGifnfY_2jjo_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/wrwERUDnDJLnhKSOWHN6HQljA~z8s7-z_awsb_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/vat4CSzeF5QqbTFs8Seiof0Xm73khTgU_tqmc_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/7WLvEGdoiXMo9QppB4I5zWYct0KCDmHt_a2lj_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/wBTVxq~aWUYeu8rceoc6NHN1UibFkU99_w7y6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/AmuE79AkACQM-u-Qy3Fdbuodyx2b4cHA_4wjt_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/IkPk9bwnpYO3tMSunoAKeBROQJVNedCt_pe0v_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/4B0ETQDACUPTzQHvzyWMJzHk0joLh21K_nhk6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/7ZYPV0jgVHxxzJIdbR5yiH-GKoXCrNDX_otu9_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/ewAq4X7gTEkxyiuFm9xgXhVT2pcOaHxM_48xa_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/CYXSqy5mPA-1dYvUZYN5yz7qLgFYIG1Z_gxtd_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/VHaqnjlgsQZ0BcyZL5qROqLrKolY0DJr_okeq_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/pz9XeWUyuebWC2x1JKy93P1RbgXwSpA3_s7dj_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/jWnParFNoWiFn782tFanJCIUxnGifnfY_2jjo_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/wrwERUDnDJLnhKSOWHN6HQljA~z8s7-z_awsb_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/vat4CSzeF5QqbTFs8Seiof0Xm73khTgU_tqmc_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/7WLvEGdoiXMo9QppB4I5zWYct0KCDmHt_a2lj_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/images/wBTVxq~aWUYeu8rceoc6NHN1UibFkU99_w7y6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/AmuE79AkACQM-u-Qy3Fdbuodyx2b4cHA_4wjt_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/IkPk9bwnpYO3tMSunoAKeBROQJVNedCt_pe0v_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/4B0ETQDACUPTzQHvzyWMJzHk0joLh21K_nhk6_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/7ZYPV0jgVHxxzJIdbR5yiH-GKoXCrNDX_otu9_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/ewAq4X7gTEkxyiuFm9xgXhVT2pcOaHxM_48xa_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/CYXSqy5mPA-1dYvUZYN5yz7qLgFYIG1Z_gxtd_4.jpg",
                 @"http://bsyimg5.cdn.krcom.cn/stream/VHaqnjlgsQZ0BcyZL5qROqLrKolY0DJr_okeq_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/pz9XeWUyuebWC2x1JKy93P1RbgXwSpA3_s7dj_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/jWnParFNoWiFn782tFanJCIUxnGifnfY_2jjo_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/wrwERUDnDJLnhKSOWHN6HQljA~z8s7-z_awsb_4.jpg",
                 @"http://bsyimg6.cdn.krcom.cn/stream/vat4CSzeF5QqbTFs8Seiof0Xm73khTgU_tqmc_4.jpg"
                 
                 ];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn addTarget:self action:@selector(testReview) forControlEvents:UIControlEventTouchUpInside];
    btn.frame = CGRectMake(100, 100, 100, 100);
    btn.backgroundColor = [UIColor redColor];
    [self.view addSubview:btn];
    
    UITableView *tab = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MPT_ScreenW, MPT_ScreenH) style:UITableViewStylePlain];
    tab.delegate = self;
    tab.dataSource = self;
    
    [self.view addSubview:tab];
    
    
    
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)testReview
{
    if([SKStoreReviewController respondsToSelector:@selector(requestReview)]){
        [SKStoreReviewController requestReview];
    }else{
        NSString  * nsStringToOpen = [NSString  stringWithFormat: @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=481587094"];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return aryImags.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"cellID";
    MPFImageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (cell == nil)
    {
        cell = [[MPFImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    [cell setCellContent:aryImags[indexPath.row]];
    
    return cell;
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
